<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<br>
<br>
<br>
<br>
 <div id='form' align=center style="height:100px"></div>
<script>
var userName="<c:out value='${model.userName}'/>";
  Ext.onReady(function() {
       var  form =new Ext.form.FormPanel({
	         e1:'form',
			 defaultType:'textField',
	         labelAlign:'right',
	         border:false,
	         labelWidth:100,
	         width:300,
	         frame:true,
	         title:'修改密码',
	         height:200,
	         url:g_rootPath+"security/updatePassword.html",
	        	 items:[{
			          fieldLabel:'用户名',xtype:'textfield',id:'userName',name:'userName',readOnly:true,value:userName
			         },{
			         fieldLabel:'原密码',xtype:'textfield',id:'oldPassword',name:'oldPassword',inputType:'password'
			         },{
			         fieldLabel:'新密码',xtype:'textfield', id:'newPassword',name:'newPassword',inputType:'password'
			         },{
			         fieldLabel:'重复新密码',xtype:'textfield',id:'repetition',name:'repetition',inputType:'password'
			         }], 
	      		  buttons:[{text:'提交',
	      		     handler:function(){
				           var userName=Ext.get("userName").getValue();
					                   if(userName==""){
					                     Ext.Msg.alert("警告","用户名不能为空！");
					                     return;
			              }
			               var oldPassword=Ext.get("oldPassword").getValue();
			              if(oldPassword==""){
			                Ext.Msg.alert("警告","原密码不能为空！");
			                return;
			              }
			               var newPassword=Ext.get("newPassword").getValue();
			              if(newPassword==""){
			                Ext.Msg.alert("警告","新密码不能为空！");
			                return;
			              }
			              var newPassword=Ext.get("newPassword").getValue();
			              var repetition=Ext.get("repetition").getValue();
			              if(newPassword!=repetition) {	
			              Ext.Msg.alert("警告","两次输入的密码不一致，请检查后重试");
					       	return;
			              }
			              
				        form.getForm().submit({
				           success:function(form,action){
				      		 Ext.Msg.alert("提示信息",action.result.info);
			   				   form.reset();
				           },
				           failure:function(form,action){
						       Ext.Msg.alert("提示信息","修改密码发生错误:"+action.result.info);
						       form.reset();
		          		   }
        				 })
	          	   }
         	   },{
         	   text:'重置',
         	     handler:function(){
         	       form.getForm().reset();
         	       }
         	   }]
});
         form.render("form");
})
</script>

